#include <iostream>
#include "contacts_1.pb.h"

using namespace std;

int main()
{
    string people_str;
    if(1)
    {
        contacts::PeopleInfo people;
        people.set_age(20);
        people.set_name("张珊");
        
        // 调⽤序列化⽅法，将序列化后的⼆进制序列存⼊string中
        if(!people.SerializeToString(&people_str)){
            cout << "序列化联系⼈失败." << endl;
        }
        // 打印序列化结果
         cout << "序列化后的 people_str: " << people_str << endl;
    }   
    
    if(1)
    {
         contacts::PeopleInfo people;
         if(!people.ParseFromString(people_str))
         {
            cout << "反序列化出联系⼈失败." << endl;
         }
         // 打印结果
        cout << "Parse age: " << people.age() << endl; 
        cout << "Parse name: " << people.name() << endl;
    }
}